Skip to content

estdlib: add string:to_integer/1#2368

Open
pguyot wants to merge 1 commit into
atomvm:release-0.7from
pguyot:w29/string-to-integer
Open

estdlib: add string:to_integer/1#2368
pguyot wants to merge 1 commit into
atomvm:release-0.7from
pguyot:w29/string-to-integer

Conversation

@pguyot

@pguyot pguyot commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Parse a leading (optionally signed) integer from a string, returning {Int, Rest} or {error, no_integer}, matching the OTP string:to_integer/1 semantics. Add a test_to_integer/0 case in test_string.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

@petermm

petermm commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

AMP found so many OTP behavior discrepancies/gaps that I asked it to implement one with better parity:
https://github.com/petermm/AtomVM/tree/fix/string-to-integer-chardata

of course more code, your call..

btw notice how test_string seems to be missing from tests/libs/estdlib/tests.erl

Parse a leading optionally signed ASCII integer from unicode:chardata(),
returning {Int, Rest} or {error, no_integer | badarg}. Accept flat lists,
binaries, and mixed/deep chardata; keep binary remainders for pure binary
input; validate the maximal leading +-/digit run (OTP take semantics);
and reject malformed UTF-8 and improper list spines encountered while
parsing.

Register test_string in the estdlib suite and cover binary/mixed input,
grammar boundaries, badarg cases, and AtomVM bigint limits.

Co-authored-by: Paul Guyot <pguyot@kallisys.net>
Signed-off-by: Peter M <petermm@gmail.com>
@pguyot
pguyot force-pushed the w29/string-to-integer branch from a178782 to f01ee59 Compare July 20, 2026 19:44
@pguyot

pguyot commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator Author

AMP found so many OTP behavior discrepancies/gaps that I asked it to implement one with better parity: https://github.com/petermm/AtomVM/tree/fix/string-to-integer-chardata

of course more code, your call..

btw notice how test_string seems to be missing from tests/libs/estdlib/tests.erl

We can do chardata indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants